<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="com.beans.*,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel = "stylesheet" href = "style/Global.css">
</head>
<body>
	 <%! int notice_id; %>
	<% 
    NoticeForm noticeForm=(NoticeForm)session.getAttribute("noticeform");

    notice_id=noticeForm.getNoticeId();
    String title=noticeForm.getTitle();
	String description=noticeForm.getDescription();
	String creatorid=noticeForm.getCreatorId();
	String creatorname=noticeForm.getCreatorName();
	Date date = noticeForm.getCreatedDate();
	
	request.setAttribute("notice_id",notice_id);
	
%>
	<div id = "noticeview">
		<div id = "noticeheading">
			<span id = "noticetitle">
				<%=title%>
			</span>
			
			<%			if((session.getAttribute("userid").toString().equals(creatorid)) ||
						(session.getAttribute("user_type").toString().equals("admin")))
						{ %>
			<a class = "btndelete" href = "DeleteNoticeAction.do?notice_id=<%=notice_id%>" >Delete</a>&nbsp;&nbsp;
			<%} %>
			
			
			<span id = "createddate">
				on&nbsp;<%=date %>&nbsp;&nbsp;
			</span>
			<span id = "creatorname">
				by&nbsp; <%=creatorname %>&nbsp;
			</span>			
			
		</div>
		<br>
		<div id = "description"><%=description %>></div>
	</div>
	<form id = "commentform" action="CommentForm.do?notice_id=<%=notice_id%>" method="post">
	<div id = "addcomment">Add Comment</div>
	<input id = "txtcomment" type = "text" name="description"><br>
	<div>
		<input id = "btnsubmit" type="submit" name = "submit" value = "Submit">
	</div>
	</form>
	
	<div id = "commentonnotice">
	<%!ArrayList<CommentForm> alist=null; %>
<% 
   alist=(ArrayList<CommentForm>)request.getAttribute("listComments");
%>
	<ul>
		<%
			for (CommentForm commentForm :alist) {
				String comment_creator = commentForm.getCreatedById();
				int cid=commentForm.getId();
				String desc = commentForm.getDescription();
				String notice_creatorid=commentForm.getCreatedById();
		%>
			
		<li>
			<div class = "commentedby"><%=comment_creator%>
				<%			if((session.getAttribute("userid").toString().equals(notice_creatorid)) ||
						(session.getAttribute("user_type").toString().equals("admin")))
						{ %>
	<form method="post" action="DeleteComment.do?cid=<%=cid%>">					
	      <input class = "btndelete" type="submit" value="x">
	</form>	
<%	}%>
	<div class = "createdon"><%=commentForm.getCreatedDate() %>&nbsp;&nbsp;&nbsp;</div>
			</div>
			<div class = "commenttext"><%=desc%> </div>
		</li>
		<%}%>
	</ul>
	</div>
	
</body>
</html>